<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>新增专家</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./js/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js"
            charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>

    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form"  method="post" enctype="multipart/form-data">

            <div class="layui-form-item">
                <label for="projectName" class="layui-form-label"> <span
                        class="x-red">*</span>项目名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="projectName" name="projectName" lay-verify="projectName"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="projectCategory" class="layui-form-label"> <span
                        class="x-red">*</span>项目类型
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="projectCategory" name="projectCategory" lay-verify="projectCategory"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="isEvaluated" class="layui-form-label">
                    项目状态：1待抽签 ;；；
                </label>
                <div class="layui-input-inline">
                    <select name="isEvaluated" id="isEvaluated">
                        <option value="1">1待抽签</option>
                        <option value="2">2随机抽签中</option>
                        <option value="3">3补抽中</option>
                        <option value="4">4抽签已完成（待登记）</option>
                        <option value="5">5登记成功（已经登记完专家到场情况，项目结束）</option>

                    </select>

                </div>
            </div>

            <div class="layui-form-item">
                <label for="professorNum" class="layui-form-label"> <span
                        class="x-red">*</span>专家人数（需要评标人数：自定义）
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="professorNum" name="professorNum" lay-verify="professorNum"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="prochaseMode" class="layui-form-label"> <span
                        class="x-red">*</span>采购方式
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="prochaseMode" name="prochaseMode" lay-verify="prochaseMode"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>


            <div class="layui-form-item">
                <label for="departmentId" class="layui-form-label">
                    采购部门id（外键：引用department表的id）
                </label>
                <div class="layui-input-inline">
                    <select name="departmentId" id="departmentId">
                          <option>1</option>
                          <option>2</option>
                          <option>3</option>
                    </select>

                </div>
            </div>

            <div class="layui-form-item">
                <label for="budget" class="layui-form-label"> <span
                        class="x-red">*</span>预算
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="budget" name="budget" lay-verify="budget"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="announceDate" class="layui-form-label"> <span
                        class="x-red">*</span>采购公告时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="announceDate" name="announceDate" lay-verify="announceDate"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="openDate" class="layui-form-label"> <span
                        class="x-red">*</span>开标时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="openDate" name="openDate" lay-verify="openDate"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="address" class="layui-form-label"> <span
                        class="x-red">*</span>开标地点
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="address" name="address" lay-verify="address"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="linkMan" class="layui-form-label"> <span
                        class="x-red">*</span>项目联系人姓名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="linkMan" name="linkMan" lay-verify="linkMan"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="mobliePhone" class="layui-form-label"> <span
                        class="x-red">*</span>项目联系人电话
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="mobliePhone" name="mobliePhone" lay-verify="mobliePhone"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="fujian" class="layui-form-label"> <span
                        class="x-red">*</span>项目文件
                </label>
                <div class="layui-input-inline">
                    <input type="file" id="fujian" name="fujian" lay-verify="fujian"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="createBy" class="layui-form-label"> <span
                        class="x-red">*</span>创建者
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="createBy" name="createBy" lay-verify="createBy"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="registerTime" class="layui-form-label"> <span
                        class="x-red">*</span>报道时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="registerTime" name="registerTime" lay-verify="registerTime"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="registerAddress" class="layui-form-label"> <span
                        class="x-red">*</span>报道地点
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="registerAddress" name="registerAddress" lay-verify="registerAddress"
                           required="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>



            <div class="layui-form-item">
                <label  class="layui-form-label"></label>
                <label  class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript" src="./js/xcity.js"></script>
<script>


    layui.use([ 'form', 'laydate','layer', 'jquery','code'],
        function() {
            var $ = layui.jquery;
            form = layui.form;
            var layer = layui.layer;
            var laydate=layui.laydate;

            laydate.render({
                elem : '#announceDate'
                ,trigger: 'click',
                format:'yyyy-MM-dd'
            });
            laydate.render({
                elem : '#openDate'
                ,trigger: 'click',
                format:'yyyy-MM-dd'
            });
            laydate.render({
                elem : '#registerTime'
                ,trigger: 'click',
                format:'yyyy-MM-dd'
            });


            //自定义验证规则
              /*            form.verify({

                professorName : function(value) {
                    if (value.length < 2||value.length >12) {
                        return '用户名必须是2-12个字符';
                    }
                },
                identityNumber : [ /\d{17}(\d|X)$/, '身份证必须是18位' ]

            });*/



            //监听提交
            form.on('submit(add)',
                function(data) {
                    //发异步，把数据提交给
                    /*                    $.post("projectAdd.jhtml",data.field,function(r){
                        alert("data.field>>>>"+data.field);
                        alert("r>>>>"+r);
                        alert("r.msg>>>>"+r.msg);
                        if(r.code==0){
                            parent.layer.alert("增加成功", {
                                icon : 6
                            },function(index,item){
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        }else{
                            parent.layer.alert("增加失败，请核对", {
                                icon : 1
                            });
                        }
                    });*/

                    var f=new FormData($("form")[0]);
                    console.log(f.keys());

                    $.ajax({
                        url:"projectAdd",
                        type:"post",
                        data:f,
                        processData:false,
                        contentType:false,
                        success:function(data){

                            alert(data.code);
                            if(data.code==0){
                                layer.alert("增加成功", {
                                        icon: 6
                                    },
                                    function() {
                                        // 获得frame索引
                                        var index = parent.layer.getFrameIndex(window.name);
                                        //关闭当前frame
                                        parent.layer.close(index);
                                        xadmin.close();
                                        xadmin.father_reload();
                                        return false;

                                    });


                            }else {
                                layer.alert("增加失败",{
                                    icon: 6
                                })
                            }

                        },
                        error:function(e){
                            alert("错误！！");
                        }

                    });


                    return false;
                });

        });
</script>

</body>

</html>